const fs = require("fs");
const path = require("path");

// 更新所有源文件中的相对路径引用
const srcDir = path.join(__dirname, "..", "src");
const files = fs.readdirSync(srcDir).filter(file => file.endsWith(".js"));

console.log("Updating file references in source files...");

files.forEach(file => {
  const filePath = path.join(srcDir, file);
  let content = fs.readFileSync(filePath, "utf8");

  // 更新相对路径引用
  content = content.replace(/\.\.\/config\.json/g, "../config.json");
  content = content.replace(/\.\//g, "../");

  fs.writeFileSync(filePath, content, "utf8");
  console.log(`Updated ${file}`);
});

console.log("File references updated successfully.");
